// const { json } = require("express");

// const {Calendar} = require('vant');
// import { Calendar } from 'vant';

new Vue({
    el: '#app',
    data: function () {
        return {
            calendarText: '',
            calendarShow: false,
            checkDaysArr :[],
            // 日历
            currentDay: 1, // 当前天
            currentMonth: 1, // 当前月
            currentYear: 1970,
            currentWeek: 0, // 一号所在的星期
            days: [], // 当月所有天数
            content: {},
            sign_days: [], // 签到日期
            is_sign: false,
            currentPlan: {},
            selectItem: '2021',
            items: [
                {id:'2021', name: '2021年05月15日'},
            ],
            selectMonth:'1',
            monthOptions:[],
            selectTypeId:'',
            selectTypeValue:'',
            allRepairTypeOptions:[
                {id:'',value:'请选择维修类型'},
                // {id:'1',value:'水电工'},
                // {id:'2',value:'煤气工'},
            ],
            allRepairPeople:[
                {id:'',value:'请选择值班维修人员'},
            ],
            repairPeopleStaffId:'',
            repairPeopleStaffValue:'',
            querySelectTypeId:'',
            querySelectTypeValue:'',
            beginWorkTime:'',
            bottomId:null,
            personList:'',
            isShow:-1,
            chooseNum:0,
            showSchedul:false, //显示排班弹框-用作动画
            showSchedulAll:false, //显示排班弹框

            showTime:false, //显示时间弹框-用作动画
            showTimeAll:false, //显示时间弹框
            workStartTime_1:'',
            workEndTime_1:'',
            workStartTime_2:'',
            workEndTime_2:'',
            typeTime:'00',
            userWorkId:'',
            repairType:'',
            staffId:'',

            adduserWorkId:'',
            addrepairType:'',


            typeRemove:'0',
            nowClickIndex:'', //删除的是某一个人的位置 -记录位置
            removeID:'',//删除时间段的位置
            popupRemoveConfim:false,//删除确认框
            showErrorMsg:false,
            errormsg:'',
            addTimeIndex:'',
            removeUserWorkId:'', //删除排班编号


            searchDate:'',
            timevalue:'',

            addDay:'', //哪一天的日期下面进行添加排班
            checkStartDay:'',//选中的开始日期
            checkEndDay:'',//选中的结束日期

            loading:true,
            host: window.location.protocol+'//'+window.location.host,
            communityId:'',
            msg:'',
            errorPopup:false,
            triggerType:'',
            triggerAddRepairType:'',
            triggerAddRepair:"",
            select_time:'上班时间段',
            bstap:true,//防重复点击
            bstapBtn:true,
            removeBstap:true,
            removeBstapBtn:true,
            removeDay:'',
            localStorageCommunityId:'',

            triggerStreet:'',
            triggerStreetValue:'',
            triggerStreetId:'',
            triggerStreetOptions:[
                {id:'',value:'请选择街道'},
            ],
            removesubScribeState:'',


            triggerArea:'',
            triggerAreaValue:'',
            triggerAreaId:'',
            triggerAreaOptions:[
                {id:'',value:'请选择片区'},
            ],


            triggerCommunity:'',
            triggerCommunityValue:'',
            triggerCommunityId:'',
            triggerCommunityOptions:[
                {id:'',value:'请选择社区'},
            ],

            triggerVillage:'',
            triggerVillageValue:'',
            triggerVillageId:'',
            triggerVillageOptions:[
                {id:'',value:'请选择小区'},
            ],

            date: '',
            show: false,

            navCommunityInfo:[ ],
            checkCommunityVal:[],
            NowStaffName:'',

            showVillage: false,
            cascaderValue: '',
            addIndexId:0,
            clickIndex:0,
            multiColumnList:[
                {
                    id:0,
                    triggerVillageValue:'',
                    triggerVillageId:'',
                    showRemoveIcon:false
                }
            ],
            requestHeaders:'',
        }
    },
    created() {
        this.getComunity();
        var localStorageCommunityId=JSON.parse(localStorage.getItem('hc_currentCommunityInfo'))
        if(localStorageCommunityId){
            this.communityId=localStorageCommunityId.communityId?localStorageCommunityId.communityId:this.getUrlParam("communityId");
        }else{
            this.communityId=this.getUrlParam("communityId");
        }
        this.requestHeaders=getRequestHeaders('00',this.communityId);//获取请求头
        console.log(this.requestHeaders)
        console.log(this.localStorageCommunityId)
        // this.searchDate=this.getUrlParam("searchDate")?this.getUrlParam("searchDate"):'';
        // this.selectTypeId=this.getUrlParam("selectTypeId")?this.getUrlParam("selectTypeId"):'';
        // this.selectTypeValue=this.getUrlParam("selectTypeValue")?this.getUrlParam("selectTypeValue"):'';
        this.queryRepairOptions();
        //this.querySteeet();
        this.getSign();
        let date = new Date();
        var date1=date.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,''); // 2020/01/01
        var today =date1.split('/')[0] + '-'+this.addZero(date1.split('/')[1]) + '-' + this.addZero(date1.split('/')[2])// // 2020-01-01
        // console.log(date1,today)
        this.searchDate=today;
        //请求小区列表接口
        //this.listEnterCommunity();

    },
    mounted(){
        //this.getComunity();
        var that=this;
        this.triggerType = new MobileSelect({
            trigger: '#triggerType',
            title: '维修类型',
            wheels: [
                {data:that.allRepairTypeOptions}
            ],
            position:[0], //初始化定位
            callback:function(indexArr, data){
                // console.log(data);
                if(that.querySelectTypeValue==data[0].value){
                    return
                }
                that.querySelectTypeValue=data[0].value;
                that.querySelectTypeId=data[0].id;
                that.getPersonNum();
            }
        });

        //维修类型
        this.triggerAddRepairType = new MobileSelect({
            trigger: '#triggerAddRepairType',
            title: '维修类型',
            wheels: [
                {data:that.allRepairTypeOptions}
            ],
            position:[0], //初始化定位
            callback:function(indexArr, data){
                that.selectTypeValue=data[0].value;
                that.selectTypeId=data[0].id;
                // console.log(data);
                that.allRepairPeople=[
                    {id:'',value:'请选择值班维修人员'}
                ];
                that.repairPeopleStaffValue='请选择值班维修人员';
                that.repairPeopleStaffId='';

                that.queryRepairpeople();
                //根据维修类型进行 --条件筛选
            }
        });


        //维修人员
        this.triggerAddRepair = new MobileSelect({
            trigger: '#triggerAddRepair',
            title: '维修人员',
            wheels: [
                {data:that.allRepairPeople}
            ],
            position:[0], //初始化定位
            callback:function(indexArr, data){
                console.log(data);
                that.repairPeopleStaffValue=data[0].value;
                that.repairPeopleStaffId=data[0].id;
            },
        });



        // 街道
        // this.triggerStreet = new MobileSelect({
        // 	trigger: '#triggerStreet',
        // 	title: '请选择街道',
        // 	wheels: [
        // 		{data:that.triggerStreetOptions}
        // 	],
        // 	position:[0], //初始化定位
        // 	callback:function(indexArr, data){
        // 		console.log(data);
        // 		that.triggerStreetValue=data[0].value;
        // 		that.triggerStreetId=data[0].id;
        // 		that.triggerCommunityId='';
        // 		that.triggerVillageOptions=[
        // 			{id:'',value:'请选择小区'}
        // 		]
        // 		that.triggerVillageValue='请选择小区';
        // 		that.triggerVillageId='';
        // 		that.triggerVillage.updateWheel(0, that.triggerVillageOptions);
        // 		that.queryArea();//查询片区
        // 		that.queryCommunity();//查询社区
        //
        // 	},
        // });
        //
        // // 片区
        // this.triggerArea = new MobileSelect({
        // 	trigger: '#triggerArea',
        // 	title: '请选择片区',
        // 	wheels: [
        // 		{data:that.triggerAreaOptions}
        // 	],
        // 	position:[0], //初始化定位
        // 	callback:function(indexArr, data){
        // 		console.log(data);
        // 		that.triggerAreaValue=data[0].value;
        // 		that.triggerAreaId=data[0].id;
        // 		that.triggerCommunityOptions=[
        // 			{id:'',value:'请选择社区'}
        // 		]
        // 		that.triggerCommunityValue='请选择社区';
        // 		that.triggerCommunityId='';
        // 		that.triggerCommunity.updateWheel(0, that.triggerCommunityOptions);
        // 		that.queryCommunity(that.triggerAreaId);//查询社区
        // 	},
        // });
        //
        // // 社区
        // this.triggerCommunity = new MobileSelect({
        // 	trigger: '#triggerCommunity',
        // 	title: '请选择社区',
        // 	wheels: [
        // 		{data:that.triggerCommunityOptions}
        // 	],
        // 	position:[0], //初始化定位
        // 	callback:function(indexArr, data){
        // 		console.log(data);
        // 		that.triggerCommunityValue=data[0].value;
        // 		that.triggerCommunityId=data[0].id;
        // 		that.queryVillage();
        // 	},
        // });

        // 具体小区
        // this.triggerVillage = new MobileSelect({
        //     trigger: '#triggerVillage',
        //     title: '请选择小区',
        //     wheels: [
        //         {data:that.triggerVillageOptions}
        //     ],
        //     //many_suiuai:'quehaialqhoon',
        //     position:[0], //初始化定位
        //     callback:function(indexArr, data){
        //         console.log(data);
        //         that.triggerVillageValue=data[0].value;
        //         that.triggerVillageId=data[0].id;
        //     },
        // });
    },
    filters: {
        subStringThree: function (value) {
            if (!value) return ''
            return value.substring(0,3)

        }
    },
    methods: {
        onVantConfirm(date) {
            console.log(date,'结束')
            this.calendarShow = false;
            this.calendarText = `选择了 ${date.length} 个日期`;
            console.log('点击日期后结果',date,'结束')

            const [start, end] = date;
            this.show = false;
            console.log(`${this.formatDate(start)} - ${this.formatDate(end)}`,'第二');
            //console.log(    `${date.getMonth() + 1}/${date.getDate()}`,'这个是新结果');
        },

        onClose() {
            console.log('关闭页面');
                this.calendarShow = false;
        },
        onVantClose(){
            console.log('onVantClose关闭页面');
            this.calendarShow = true;
        },

        formatDate(date) {
            return `${date.getMonth() + 1}/${date.getDate()}`;
        },
        onConfirm(date) {
            const [start, end] = date;
            this.show = false;
            this.date = `${this.formatDate(start)} - ${this.formatDate(end)}`;
        },


        // 查询维修类型
        queryRepairOptions(){
            var that=this;
            var url=this.host+'/app/repair.listRepairSettings';
            console.log('communityId:'+this.communityId)
            var params={
                communityId:'',
                row:50,
                page:1
            }
            $.ajax({
                url : url,
                type: 'GET',
                dataType:'json',
                headers:that.requestHeaders,
                data: params,
                success : function (res){
                    console.log('查询维修类型',res);
                    if(res.code=='0'){
                        if(res.data.length>0){
                            var list=res.data;
                            list.forEach(function(value,index) {
                                that.allRepairTypeOptions.push({
                                    id:value.repairType,
                                    value:value.repairTypeName
                                })

                            });
                            // console.log(that.allRepairTypeOptions)
                            that.triggerType.updateWheel(0, that.allRepairTypeOptions);
                            that.triggerAddRepairType.updateWheel(0, that.allRepairTypeOptions);
                        }else{

                        }
                    }else{
                        that.errorPopup=true;
                        that.msg=res.msg
                    }
                },
                error:function(res){
                    that.errorPopup=true;
                    that.msg=res.responseText?res.responseText:'请求超时'
                    console.log(res.responseText)

                }
            })
        },
        //查询维修人员
        queryRepairpeople(){
            var that=this;
            var url=this.host+'/app/repair.listRepairTypeUsers';
            console.log(this.selectTypeId)
            var params={
                communityId:'',
                row:50,
                page:1,
                repairType:this.selectTypeId
            }
            $.ajax({
                url : url,
                type: 'GET',
                dataType:'json',
                headers:that.requestHeaders,
                data: params,
                success : function (res){
                    console.log('查询维修人员',res);
                    if(res.code=='0'){
                        if(res.data.length>0){
                            var list=res.data;

                            that.allRepairPeople=[
                                {id:'',value:'请选择值班维修人员'}
                            ]
                            list.forEach(function(value,index) {
                                that.allRepairPeople.push({
                                    id:value.staffId,
                                    value:value.staffName
                                })
                            });
                            console.log(that.allRepairPeople)
                            that.triggerAddRepair.updateWheel(0, that.allRepairPeople);

                        }else{
                            that.allRepairPeople=[
                                {id:'',value:'请选择值班维修人员'}
                            ]
                            that.repairPeopleStaffValue='请选择值班维修人员';
                            that.repairPeopleStaffId='';
                            console.log(that.allRepairPeople)
                            that.triggerAddRepair.updateWheel(0, that.allRepairPeople);
                        }
                    }else{
                        that.allRepairPeople=[
                            {id:'',value:'请选择值班维修人员'}
                        ]
                        that.repairPeopleStaffValue='请选择值班维修人员';
                        that.repairPeopleStaffId='';
                        that.triggerAddRepair.updateWheel(0, that.allRepairPeople);
                        that.errorPopup=true;
                        that.msg=res.msg
                    }
                },
                error:function(res){
                    that.allRepairPeople=[
                        {id:'',value:'请选择值班维修人员'}
                    ]
                    that.repairPeopleStaffValue='请选择值班维修人员';
                    that.repairPeopleStaffId='';
                    that.triggerAddRepair.updateWheel(0, that.allRepairPeople);
                    that.errorPopup=true;
                    that.msg=res.responseText?res.responseText:'请求超时'
                    console.log(res.responseText)

                }
            })
        },

        getComunity(){
            var that=this;
            var params={
                _uid: '123mlkdinkldldijdhuudjdjkkd',
                page: 1,
                row: 100
            }

            $.ajax({
                url : this.host+'/callComponent/nav/getCommunitys',
                type: 'get',
                dataType:'json',
                data: params,
                success : function (res){
                    //this.navCommunityInfo = res.communitys;
                    that.navCommunityInfo = [{}];
                    // that.triggerVillageOptions = [{id:0,triggerVillageValue:'111',triggerVillageId:'222',showRemoveIcon:false}];
                    that.triggerVillageOptions=[
                        {value:'',text:'请选择小区'}
                    ]
                    var list=res.communitys;
                    var str = '';
                    list.forEach(function(value,index) {
                        str += '<option value="'+value.communityId+'">'+value.name+'</option>';
                        // that.navCommunityInfo.push({
                        //     id:value.communityId,
                        //     value:value.name
                        // })

                        that.triggerVillageOptions.push({
                            value:value.communityId,
                            text:value.name
                        })
                    });

                    //this.navCommunityInfo = that.navCommunityInfo;


                    // if(str != ''){
                    //     //console.log('以暴力替换');
                    //     $('#people').append(str);
                    //     $('#people').multiSelect({noneText:'请选择小区','modalHTML': '<div class="multi-select-modal">'});
                    // }else {
                    //     $('#people').multiSelect({noneText:'暂无小区信息','modalHTML': '<div class="multi-select-modal">'});
                    // }

                }
            })

        },


        /**
         * 获取签到日期
         */
        getSign () {
            let date = new Date();

            let year = date.getFullYear(); //获取当前年份
            let mon = date.getMonth() + 1; //获取当前月份
            let da = date.getDate(); //获取当前日
            if(mon <10){
                mon = '0'+mon;
            }
            if(da < 10){
                da = '0'+da;
            }

            this.startDate = year+'年'+mon+'月'+da+'日';
            this.bindDate = year+'年'+mon+'月'+da+'日';
            this.beginWorkTime = year+'-'+mon+'-'+da
            // 模拟数据
            this.initData(null);
            this.getPersonNum();
        },
        initData (cur) {
            var date;
            if (cur) { // 切换上一月、下一月
                date = new Date(cur);
            } else {
                var now = new Date(); // 此处取本机时间，应改为服务器时间
                var d = new Date(this.formatDate(now.getFullYear(), now.getMonth() + 1, 1));
                d.setDate(35); // 设置天数为35天（32~59都可以，既设置到下一个月的某一天）
                date = new Date(this.formatDate(d.getFullYear(), d.getMonth(), 1));
            }
            this.currentDay = new Date().getDate(); // 今日日期 几号
            this.currentYear = date.getFullYear(); // 当前年份
            this.currentMonth = date.getMonth() + 1; // 当前月份
            this.currentWeek = date.getDay(); // 当前月1号是星期几？ 0表示星期天
            // 当前月最后一天是星期几？ 0表示星期天
            this.nextWeek = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDay();
            var str = this.formatDate(this.currentYear, this.currentMonth, 1); // 2020/01/01
            var nextStr = new Date(date.getFullYear(), date.getMonth() + 1, 0).toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,''); // 2020/01/01
            this.days = []; // 初始化日期
            // 设置上一个月 需显示 的最后几天  铺满一周
            for (var i = this.currentWeek; i > 0; i--) {
                var d = new Date(str);
                d.setDate(d.getDate() - i);
                var dayobject = {
                    day: d,
                    text:this.isText(d),
                    isSign: this.isVerDate(d),
                    isSigned: this.isSigned(d),
                    isToday:this.isToday(d),
                    isType:this.isType(d)
                }; // 用一个对象包装Date对象  以便为以后预定功能添加属性
                this.days.push(dayobject); // 将日期放入data 中的days数组 供页面渲染使用
            }
            // console.log(this.days)
            // 显示当前月的天数  第二个循环为 j<= 36- this.currentWeek，
            // 因为1号是星期六的时候当前月需显示6行，如2020年8月
            this.num = 0; //第几个月 每遇到1号加1
            for (var j = 0; j <= 36 - this.currentWeek; j++) {
                var d = new Date(str);
                d.setDate(d.getDate() + j);
                var dddd = d.getDate();
                var dayobject = {
                    day: d,
                    text:this.isText(d),
                    isSign: this.isVerDate(d),
                    isSigned: this.isSigned(d),
                    isToday:this.isToday(d),
                    isType:this.isType(d)
                };
                // console.log(2,d)
                if (dddd == 1) {
                    this.num++
                }
                if (this.num == 2) {
                    break
                }
                this.days.push(dayobject);
            }
            // console.log('当前月1号是星期' + this.currentWeek)
            // console.log('当前月最后一天是星期' + this.nextWeek)
            // 设置下一个月 需显示 的最前几天铺满一周
            for (var k = 1; k <= 6 - this.nextWeek; k++) {
                var d = new Date(nextStr);
                d.setDate(d.getDate() + k);
                var dayobject = {
                    day: d,
                    text:this.isText(d),
                    isSign: this.isVerDate(d),
                    isSigned: this.isSigned(d),
                    isToday:this.isToday(d),
                    isType:this.isType(d)
                }; // 用一个对象包装Date对象  以便为以后预定功能添加属性
                this.days.push(dayobject); // 将日期放入data 中的days数组 供页面渲染使用
            }
            // console.log(this.days)
        },
        /**
         * 判断该日期是否有任务
         * @param d
         * @returns {boolean}
         */
        isVerDate(d) {
            var signdays = [];
            var r = d.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,'');
            var t;
            var sinday=[];
            for (var i in this.sign_days) {
                signdays.push(this.sign_days[i].day);
            }
            var t = signdays.indexOf(r) == '-1' ? false : true;
            return t;
            // return signdays.includes(d.toLocaleDateString());//ie不兼容
        },
        /**
         * 判断该日期是否有任务并且已完成
         * @param d
         * @returns {boolean}
         */
        isSigned (d) {
            var signdays = [];
            for (var i in this.sign_days) {
                if (this.sign_days[i].is_sign) {
                    signdays.push(this.sign_days[i].day);
                }
            }
            var r = d.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,'');
            var t = signdays.indexOf(r) == '-1' ? false : true;

            return t;
            // return signdays.includes(d.toLocaleDateString());
        },
        isText(d){
            var r = d.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,'');
            for (var i in this.sign_days) {
                if (this.sign_days[i].day==r) {
                    return this.sign_days[i].text;
                }
            }
        },
        isType(d){
            var r = d.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,'');
            for (var i in this.sign_days) {
                if (this.sign_days[i].day==r) {
                    return this.sign_days[i].orgName;
                }
            }
        },
        isToday(d){
            var r = d.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,'');
            var now=new Date();
            var now_time=now.getFullYear()+'/'+Number(now.getMonth()+1)+'/'+now.getDate();
            if(r==now_time){
                return true;
                console.log(192,now_time)
            }
        },
        /**
         * 上一月
         * @param year
         * @param month
         */
        pickPre (year, month) {
            var d = new Date(this.formatDate(year, month, 1));
            d.setDate(0);
            this.selectMonth=d.getMonth() + 1
            this.initData(this.formatDate(d.getFullYear(), this.selectMonth, 1));
            // this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1));
        },
        /**
         * 下一月
         * @param year
         * @param month
         */
        pickNext(year, month) {
            var d = new Date(this.formatDate(year, month, 1));
            d.setDate(35);
            this.selectMonth=d.getMonth() + 1
            this.initData(this.formatDate(d.getFullYear(), this.selectMonth, 1));
            // this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1));
        },
        // 返回 类似 2020/01/01 格式的字符串
        formatDate (year, month, day) {
            month < 10 && (month = '0' + month);
            day < 10 && (day = '0' + day);
            var data = year + '/' + month + '/' + day;

            return data;
        },
        /**
         * 点击日期查询
         * @param index
         */
        dayCheck(day,flag='no') {
            var currentPlan = {
                title: '',
                date: '',
                list: []
            };
            var date1=day.day.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,''); // 2020/01/01
            currentPlan.date =date1.split('/')[1] + '月' + date1.split('/')[2] +
                '日';
            this.addDay =date1.split('/')[0] + '-'+this.addZero(date1.split('/')[1]) + '-' + this.addZero(date1.split('/')[2])


            for (var i in this.days) {
                if(this.fm(day.day)== this.fm(this.days[i].day)){
                    this.$set(this.days[i], 'isChecked', 1);
                    if(flag =='yes'){
                        if(i>20){
                            this.bottomId = 'm_second'
                        }else{
                            this.bottomId = 'm_first'
                        }
                        this.scrollTOview(this.bottomId);
                    }
                }else{
                    this.$set(this.days[i], 'isChecked', 0)
                }
            }
            // console.log(885,day)
            this.searchDate=this.addDay;
            this.$set(day, 'isChecked', 1);
            this.currentPlan = currentPlan
            //this.loading=true; //加载展示


            if(flag == 'no'){
                let hisCheckStartDay = '',hisCheckEndDay = '';
                $(".day-range-checked2").removeClass('day-range-checked2');
                if(this.checkStartDay == ''){
                    this.checkStartDay = day;
                    this.checkStartDay.text = '开始';
                    this.checkStartDay.isChecked = 0;
                    this.checkStartDay.isRangeChecked = 1;
                }else if(this.checkEndDay == ''){
                    if(this.checkStartDay.day > day.day){
                        hisCheckStartDay = this.checkStartDay;
                        hisCheckEndDay = this.checkEndDay;

                        this.checkStartDay = day;
                        this.checkStartDay.text = '开始';
                        this.checkStartDay.isChecked = 0;
                        this.checkStartDay.isRangeChecked = 1;

                        this.checkEndDay = '';
                    }else {
                        this.checkEndDay = day;
                        this.checkEndDay.text = '结束';
                        this.checkEndDay.isChecked = 0;
                        this.checkEndDay.isRangeChecked = 1;
                    }
                }else {
                    hisCheckStartDay = this.checkStartDay;
                    hisCheckEndDay = this.checkEndDay;

                    this.checkStartDay = day;
                    this.checkStartDay.text = '开始';
                    this.checkStartDay.isChecked = 0;
                    this.checkStartDay.isRangeChecked = 1;
                    this.checkEndDay = '';
                }
                if(hisCheckStartDay != '' && hisCheckStartDay != day){
                    this.$set(hisCheckStartDay, 'isChecked', 0);
                    this.$set(hisCheckStartDay, 'text', '');
                    this.$set(hisCheckStartDay, 'isRangeChecked', 0);
                }
                // console.log('this.checkStartDay',this.checkStartDay?this.changeDateType(this.checkStartDay):'未选择');
                // console.log('this.checkEndDay',this.checkEndDay?this.changeDateType(this.checkEndDay):'未选择');
                if(hisCheckEndDay != '' && hisCheckEndDay != day){
                    this.$set(hisCheckEndDay, 'isChecked', 0);
                    this.$set(hisCheckEndDay, 'text', '');
                    this.$set(hisCheckEndDay, 'isRangeChecked', 0);
                }

                if(this.checkStartDay!='' && this.checkEndDay!=''){
                     var stime = this.changeDateType(this.checkStartDay);//"2021/07/02"; //开始日期
                     var etime = this.changeDateType(this.checkEndDay);//"2021/07/09"; //结束日期

                     this.checkDaysArr = this.getdiffdate(stime,etime);
                }
            }

        },

        


        //获取两日期之间日期列表函数
        getdiffdate(stime,etime){
            //初始化日期列表，数组
            var diffdate = new Array();
            var i=0;
            // $(".day-range-checked2").removeClass('day-range-checked2');
            //开始日期小于等于结束日期,并循环
            while(stime<etime){
                diffdate[i] = stime;

                //获取开始日期时间戳
                var stime_ts = new Date(stime).getTime();
                console.log('当前日期：'+stime   +'当前时间戳：'+stime_ts);

                //增加一天时间戳后的日期
                var next_date = stime_ts + (24*60*60*1000);
                $("#day_"+next_date).addClass('day-range-checked2');

                //拼接年月日，这里的月份会返回（0-11），所以要+1
                var next_dates_y = new Date(next_date).getFullYear()+'/';
                var next_dates_m = (new Date(next_date).getMonth()+1 < 10)?'0'+(new Date(next_date).getMonth()+1)+'/':(new Date(next_date).getMonth()+1)+'/';
                var next_dates_d = (new Date(next_date).getDate() < 10)?'0'+new Date(next_date).getDate():new Date(next_date).getDate();

                stime = next_dates_y+next_dates_m+next_dates_d;

                //console.log('stime',stime);
                //增加数组key this.$set(hisCheckEndDay, 'isRangeChecked', 0);
                i++;
            }
            //console.log(diffdate);
        },


        addZero(n){
            return	n=n<10?'0'+n:n;
        },
        removeZero(n){
            return n<10?Number(n):n
        },
        selectMonthChange(e){
            // console.log(e)
            // console.log(e.target.selectedIndex) // 选择项的index索引
            // console.log(e.target.value) // 选择项的value
            this.selectMonth=e.target.value;
            var D=new Date();
            var year=D.getFullYear()
            var d = new Date(this.formatDate(year, this.selectMonth, 1));
            d.setDate(0);
            this.initData(this.formatDate(d.getFullYear(), this.selectMonth, 1));
        },

        clickNowDay(){
            this.getSign();
        },
        /*查询最近15天排班*/
        getPersonNum_bak(clickDay){
            var that=this;
            var today=new Date().toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,'');
            today =today.split('/')[0] + '-'+this.addZero(today.split('/')[1]) + '-' + this.addZero(today.split('/')[2])
            var url=this.host+'/app/repair.listRecentlyDaysRepairSchedulingList';
            // console.log(that.querySelectTypeValue,that.querySelectTypeId)
            var params={
                communityId:'',
                repairType:that.querySelectTypeId,
                beginWorkTime:'',
                days:''
            }
            $.ajax({
                url : url,
                type: 'GET',
                dataType:'json',
                headers:that.requestHeaders,
                data: params,
                success : function (res){
                    // console.log(res);
                    if(res.code=='0'){
                        setTimeout(function(){
                            that.loading=false;
                        },800)
                        if(res.data.length>0){
                            var list=res.data;
                            console.log('15天排班接口',list)
                            var listArr=[];
                            list.forEach(function(item, index) {
                                var day = item.formatterWorkTime.replace('-','/');
                                day = day.replace('-','/');
                                listArr.push({
                                    day: day,
                                    is_sign: 2,
                                    text:item.names,
                                    orgName:item.orgName
                                })
                            })
                            listArr.push({
                                day: '2021/6/29',
                                is_sign: 2,
                                text:'测试',
                                orgName:''
                            })
                            listArr.push({
                                day: '2021/6/28',
                                is_sign: 2,
                                text:'2测试',
                                orgName:''
                            })

                            console.log('listArr',listArr);
                            that.sign_days = listArr;
                            // console.log(369,listArr,typeof (listArr))

                            // console.log(clickDay)
                            if(clickDay){ //新增排班成功后 定位到当前增加排班日期位置
                                console.log(962,clickDay)
                                var d=new Date(clickDay);
                                var year=d.getFullYear();
                                var month=d.getMonth()+1;
                                var days=d.getDate();
                                var day = {
                                    day:  new Date(that.formatDate(year,month, days)),
                                    text:that.isText(d),
                                    isSign: that.isVerDate(d),
                                    isSigned: that.isSigned(d),
                                    isToday:that.isToday(d)
                                };
                                d.setDate(0);
                                that.initData(that.formatDate(year, month, 1));
                                that.dayCheck(day,'yes');
                            }else{
                                that.initData(null);
                                that.initStart();
                            }
                            // if(that.searchDate){ //上个页面带入日期
                            // 	that.changeDateValue();
                            // }
                            // if(that.selectTypeId && that.selectTypeValue){//上个页面带入维修类型
                            // 	that.queryRepairpeople()
                            // }

                        }else{//无数据的展示
                            that.initData(null);
                            that.initStart();
                        }
                    }else{
                        that.loading=false;
                        that.errorPopup=true;
                        that.msg=res.msg
                    }
                },
                error:function(res){
                    that.loading=false;
                    that.errorPopup=true;
                    that.msg=res.responseText?res.responseText:'请求超时'
                }
            })
        },
        /*查询最近15天排班*/
        getPersonNum(clickDay){
            var that=this;
            var today=new Date().toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,'');
            today =today.split('/')[0] + '-'+this.addZero(today.split('/')[1]) + '-' + this.addZero(today.split('/')[2])
            var url=this.host+'/app/repair.listStaffSubscribe';
            // console.log(that.querySelectTypeValue,that.querySelectTypeId)
            var params={
                communityId:'',
                repairType:that.querySelectTypeId,
                beginWorkTime:'',
                days:'',
                beginTime:today,
                //staffId:'3021060916380000137194',

                staffId: userId,
            }
            $.ajax({
                url : url,
                type: 'GET',
                dataType:'json',
                headers:that.requestHeaders,
                data: params,
                success : function (res){
                    console.log('success',res);
                    if(res.code=='200'){
                        setTimeout(function(){
                            that.loading=false;
                        },800)
                        this.NowStaffName = '老张三';
                        $("#NowStaffName").html(this.NowStaffName);
                        console.log("this.NowStaffName-==",this.NowStaffName);
                        if(res.data.length>0){
                            var list=res.data.subscribe;
                            console.log('15天排班接口',list);

                            var listArr=[];
                            list.forEach(function(item, index) {
                                var day = item.formatterWorkTime.replace('-','/');
                                day = day.replace('-','/');
                                listArr.push({
                                    day: day,
                                    is_sign: 2,
                                    text:item.names,
                                    orgName:item.orgName
                                })
                            })
                            // listArr.push({
                            //     day: '2021/6/29',
                            //     is_sign: 2,
                            //     text:'测试',
                            //     orgName:''
                            // })
                            // listArr.push({
                            //     day: '2021/6/28',
                            //     is_sign: 2,
                            //     text:'2测试',
                            //     orgName:''
                            // })

                            console.log('listArr',listArr);
                            that.sign_days = listArr;
                            // console.log(369,listArr,typeof (listArr))

                            // console.log(clickDay)
                            if(clickDay){ //新增排班成功后 定位到当前增加排班日期位置
                                console.log(962,clickDay)
                                var d=new Date(clickDay);
                                var year=d.getFullYear();
                                var month=d.getMonth()+1;
                                var days=d.getDate();
                                var day = {
                                    day:  new Date(that.formatDate(year,month, days)),
                                    text:that.isText(d),
                                    isSign: that.isVerDate(d),
                                    isSigned: that.isSigned(d),
                                    isToday:that.isToday(d)
                                };
                                d.setDate(0);
                                that.initData(that.formatDate(year, month, 1));
                                that.dayCheck(day,'yes');
                            }else{
                                that.initData(null);
                                that.initStart();
                            }
                            // if(that.searchDate){ //上个页面带入日期
                            // 	that.changeDateValue();
                            // }
                            // if(that.selectTypeId && that.selectTypeValue){//上个页面带入维修类型
                            // 	that.queryRepairpeople()
                            // }

                        }else{//无数据的展示
                            that.initData(null);
                            that.initStart();
                        }
                    }else{
                        that.loading=false;
                        that.errorPopup=true;
                        that.msg=res.msg
                    }
                },
                error:function(res){
                    console.log('超时error',res);
                    that.loading=false;
                    that.errorPopup=true;
                    that.msg=res.responseText?res.responseText:'请求超时'
                }
            })
        },
        initStart() {
            // console.log(1006,this.beginWorkTime)
            var d=new Date(this.beginWorkTime);
            var year=d.getFullYear();
            var month=d.getMonth()+1;
            var days=d.getDate();
            // console.log(year)
            // console.log(month)
            // console.log(days)
            var day = {
                day:  new Date(this.formatDate(year,month, days)),
                text:this.isText(d),
                isSign: this.isVerDate(d),
                isSigned: this.isSigned(d),
                isToday:this.isToday(d)
            };
            d.setDate(0);
            this.initData(this.formatDate(year, month, 1));
            this.dayCheck(day,'yes');
        },
        fm(date){
            var date1=date.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,''); // 2020/01/01
            //console.log('date1=====',date1);
            return date1
        },
        scrollTOview(id){
            setTimeout(function(){
                $('#clickId').attr('href','#'+id).click();
                document.getElementById(id).scrollIntoView()
            },100)
        },
        /*查询某天排班*/
        getTodayPlace(date){
            var that = this;
            that.personList = [];
            // console.log(date)
            var d=new Date(date);
            var year=d.getFullYear();
            var month=d.getMonth()+1;
            var days=d.getDate();
            if(month <10){
                month = '0'+month;
            }
            if(days <10){
                days = '0'+days;
            }
            var daytime = year+'-'+ month+'-'+days;

            let url=this.host+'/app/repair.listDayRepairSchedulingListByManager';
            let params={
                communityId:'',
                workTime:daytime,
                repairType:that.querySelectTypeId
            }
            $.ajax({
                url : url,
                type: 'GET',
                dataType:'json',
                headers:that.requestHeaders,
                data: params,
                success : function (res){
                    console.log('查询某天排班接口',res);
                    if(res.code=='0'){
                        that.loading=false;
                        if(res.data.length>0){
                            var list=res.data;
                            that.personList = list;
                        }else{

                        }
                    }else{
                        that.loading=false;
                        that.errorPopup=true;
                        that.msg=res.msg
                    }
                },
                error:function(res){
                    that.loading=false;
                    that.errorPopup=true;
                    that.msg=res.responseText?res.responseText:'请求超时'
                }
            })

        },
        choose(index) {
            // console.log(index)
            this.chooseNum = this.chooseNum +1;
            var n = this.chooseNum % 2;
            if(n == 1){
                this.chooseFlag = true
            }else{
                this.chooseFlag = false
            };
            if(this.isShow == index){
                this.isShow = '-1';
                return;
            }
            this.isShow = index
        },
        //添加排班弹框
        addSchedul(){
            var that=this;
            this.getComunity();
            that.select_time='上班时间段';
            that.timevalue='';
            that.workStartTime_2='';
            that.workEndTime_2='';
            that.selectTypeId='';
            that.selectTypeValue='维修类型';
            that.repairPeopleStaffValue='请选择值班维修人员';
            that.repairPeopleStaffId='';
            that.triggerAreaOptions=[
                {id:'',value:'请选择片区'}
            ];
            that.triggerCommunityOptions=[
                {id:'',value:'请选择社区'}
            ];
            that.triggerVillageOptions=[
                {id:'',value:'请选择小区'}
            ];
            that.triggerVillageValue='请选择小区';
            //that.triggerArea.updateWheel(0, that.triggerAreaOptions);
            //that.triggerCommunity.updateWheel(0, that.triggerCommunityOptions);
            //that.triggerVillage.updateWheel(0, that.triggerVillageOptions);
            that.triggerStreetValue='请选择街道';
            that.triggerStreetId='';
            that.triggerAreaValue='请选择片区';
            that.triggerAreaId='';
            that.triggerCommunityValue='请选择社区';
            that.triggerCommunityId='';
            that.triggerVillageValue='请选择小区';
            that.triggerCommunityId='';
            this.showSchedulAll=true;
            setTimeout(function(){
                that.showSchedul=true;
            },50)

        },
        //关闭添加排班弹框
        closePopup(){
            var that=this;
            this.showSchedul=false;
            setTimeout(function(){
                that.showSchedulAll=false;
            },350)
        },
        //上班时间段选择弹框
        timeSelect(type,index,userWorkId,repairType){
            this.typeTime=type;//00添加时间段   01新增排班-添加时间段
            if(this.typeTime=='00'){
                this.addTimeIndex=index; //获取哪一个的添加时间段
                this.userWorkId=userWorkId; //排班编号
                this.repairType=repairType;//维修类型
                // console.log(this.userWorkId,this.repairType)
            }
            this.showTime=true;
            this.showTimeAll=true;
        },
        //关闭上班时间段弹框
        cancalTime(){
            var that=this;
            this.showTime=false;
            setTimeout(function(){
                that.showTimeAll=false;
            },400)
        },
        //确认 上班时间段弹框
        confimTime(){
            var that=this;
            if(this.typeTime=='00'){
                if(!this.workStartTime_1){
                    this.showErrorMsg=true;
                    this.errormsg='上班开始时间不能为空';
                    setTimeout(function(){
                        that.showErrorMsg=false;
                    },1500)
                    return;
                }
                if(!this.workEndTime_1){
                    this.showErrorMsg=true;
                    this.errormsg='下班结束时间不能为空';
                    setTimeout(function(){
                        that.showErrorMsg=false;
                    },1500)
                    return;
                }
                if(this.timeComparison(this.workStartTime_1,this.workEndTime_1)){
                    this.showErrorMsg=true;
                    this.errormsg='上班开始时间不能大于或等于下班结束时间';
                    setTimeout(function(){
                        that.showErrorMsg=false;
                    },1500)
                    return;
                }
                if(this.bstap==false){
                    return
                }
                //添加时间端段接口
                let url=this.host+'/app/repair.addRepairWorkTimeByManager';
                let params={
                    "communityId":this.communityId,
                    "workTime":this.addDay,
                    "repairType":this.repairType,
                    "userWorkId":this.userWorkId,
                    "beginTime":this.addDay+' '+this.workStartTime_1+':00',
                    "endTime":this.addDay+' '+this.workEndTime_1+':00',
                    "staffId":this.staffId
                }
                this.bstap=false;
                $.ajax({
                    url : url,
                    type: 'POST',
                    dataType:'json',
                    contentType: 'text/plain',
                    headers:that.requestHeaders,
                    data: JSON.stringify(params),
                    success : function (res){
                        that.bstap=true;
                        if(res.code=='200'){
                            that.personList[that.addTimeIndex].details.push({
                                "communityId":that.communityId,
                                "workTime":that.addDay,
                                "repairType":that.repairType,
                                "userWorkId":that.userWorkId,
                                "beginTime":that.workStartTime_1,
                                "endTime":that.workEndTime_1,
                                "staffId":that.staffId
                            })

                            that.showErrorMsg=true;
                            that.workStartTime_1='';
                            that.workEndTime_1='';
                            that.errormsg='新增成功！';
                            var day =that.addDay.split('-')[0] + '/'+that.removeZero(that.addDay.split('-')[1]) + '/' + that.removeZero(that.addDay.split('-')[2])
                            that.getTodayPlace(day);
                            // console.log(day)
                            setTimeout(function(){
                                that.showErrorMsg=false;
                            },1000)
                            that.showTime=false;
                            setTimeout(function(){
                                that.showTimeAll=false;
                            },400);
                        }else{
                            console.log(res)
                            that.errorPopup=true;
                            that.msg=res.msg
                        }
                    },
                    error:function(res){
                        that.bstap=true;
                        console.log(res)
                        that.errorPopup=true;
                        that.msg=res.responseText?res.responseText:'请求超时'
                    }
                })
            }else{
                if(!this.workStartTime_2){
                    this.showErrorMsg=true;
                    this.errormsg='上班开始时间不能为空';
                    setTimeout(function(){
                        that.showErrorMsg=false;
                    },1500)
                    return;
                }
                if(!this.workEndTime_2){
                    this.showErrorMsg=true;
                    this.errormsg='下班结束时间不能为空';
                    setTimeout(function(){
                        that.showErrorMsg=false;
                    },1500)
                    return;
                }
                if(this.timeComparison(this.workStartTime_2,this.workEndTime_2)){
                    this.showErrorMsg=true;
                    this.errormsg='上班开始时间不能大于或等于下班结束时间';
                    setTimeout(function(){
                        that.showErrorMsg=false;
                    },1500)
                    return;
                }
                this.showTime=false;
                this.select_time=this.workStartTime_2+"~"+this.workEndTime_2
                setTimeout(function(){
                    that.showTimeAll=false;
                },400);
                // console.log(this.workStartTime_2,this.workEndTime_2)
            }
        },
        showRemoveConfim(type,index,indexId,userSubscribeId){
            // console.log(type,index,indexId,userSubscribeId)
            //index 第几个人下面的排班详情位置
            //indexId 删除的是哪一个排班时间段位置
            this.popupRemoveConfim=true;
            this.typeRemove=type;
            if(type=='01'){
                // console.log(index,indexId)
                this.nowClickIndex=index;
                this.removeID=indexId;
                this.removesubScribeState=userSubscribeId;
            }else{
                this.removeUserWorkId=index;
                this.removeDay=indexId;
                console.log(this.removeDay)
                console.log('删除排班编号：'+this.removeUserWorkId)
            }
        },
        //确认删除
        removeConfim(){
            let that=this;
            if(this.typeRemove=='00'){//调删除接口
                let url=this.host+'/app/repair.deleteRepairSchedulingByManager';
                let params={
                    "communityId":this.communityId,
                    "userWorkId":this.removeUserWorkId,
                }
                if(that.removeBstap==false){
                    return;
                }
                that.removeBstap=false
                console.log(params)
                $.ajax({
                    url : url,
                    type: 'POST',
                    dataType:'json',
                    contentType: 'text/plain',
                    headers:that.requestHeaders,
                    data: JSON.stringify(params),
                    success : function (res){
                        console.log('删除接口',res);
                        that.removeBstap=true
                        if(res.code=='200'){
                            that.showErrorMsg=true;
                            that.errormsg='删除成功！';
                            setTimeout(function(){
                                that.showErrorMsg=false;
                            },1500)
                            that.popupRemoveConfim=false;

                            console.log(that.removeDay)
                            that.getPersonNum(that.removeDay);
                            return;
                        }else{
                            that.errorPopup=true;
                            that.msg=res.msg
                        }
                    },
                    error:function(res){
                        that.removeBstap=true
                        that.errorPopup=true;
                        that.msg=res.responseText?res.responseText:'请求超时'
                    }
                })
            }else{//时间段删除-接口调用
                let url=this.host+'/app/repair.deleteRepairWorkTimeByManager';
                let params={
                    "communityId":this.communityId,
                    "userSubscribeId":this.removesubScribeState,
                }
                if(that.removeBstapBtn==false){
                    return;
                }
                that.removeBstapBtn=false;
                $.ajax({
                    url : url,
                    type: 'POST',
                    dataType:'json',
                    contentType: 'text/plain',
                    headers:that.requestHeaders,
                    data: JSON.stringify(params),
                    success : function (res){
                        console.log(res);
                        that.removeBstapBtn=true;
                        if(res.code=='200'){
                            that.showErrorMsg=true;
                            that.errormsg='删除成功！';
                            that.personList[that.nowClickIndex].details.splice(that.removeID,1);
                            that.popupRemoveConfim=false;
                            setTimeout(function(){
                                that.showErrorMsg=false;
                            },1500)

                            return;
                        }else{
                            that.popupRemoveConfim=false;
                            that.errorPopup=true;
                            that.msg=res.msg
                        }
                    },
                    error:function(res){
                        that.removeBstapBtn=true;
                        that.popupRemoveConfim=false;
                        that.errorPopup=true;
                        that.msg=res.responseText?res.responseText:'请求超时'
                    }
                })

            }
        },
        //保存按钮 --排班时间保存
        submitSave(){},

        //新增排班提交接口
        submit_add(){
            let that=this;
            if(that.bstapBtn==false){
                return;
            }
            var communityIds = $("#people").val();
            //let url=that.host+'/app/repair.addRepairSchedulingByManager';//old api

            let url=that.host+'/app/repair.addStaffSubscribe';
            console.log(that.selectTypeId)
            console.log('now小区',communityIds);
            //console.log('check_now小区',this.checkCommunityVal);
            if(!communityIds){
                that.showErrorMsg=true;
                that.errormsg='小区不能为空';


                setTimeout(function(){
                    that.showErrorMsg=false;
                },1500)
                return
            }
            else if(that.selectTypeId==''){
                that.showErrorMsg=true;
                that.errormsg='维修类型不能为空';
                setTimeout(function(){
                    that.showErrorMsg=false;
                },1500)
                return
            }
            else if(that.repairPeopleStaffId==''){
                that.showErrorMsg=true;
                that.errormsg='维修人员不能为空';
                setTimeout(function(){
                    that.showErrorMsg=false;
                },1500)
                return
            }
            else if(that.select_time=='上班时间段' || that.select_time =='' ){
                that.showErrorMsg=true;
                that.errormsg='上班时间段不能为空';
                setTimeout(function(){
                    that.showErrorMsg=false;
                },1500)
                return
            }else if(that.timevalue==''){
                that.showErrorMsg=true;
                that.errormsg='时间间隔不能为空';
                setTimeout(function(){
                    that.showErrorMsg=false;
                },1500)
                return
            }else if(that.checkStartDay==''){
                that.showErrorMsg=true;
                that.errormsg='开始时间不能为空';
                setTimeout(function(){
                    that.showErrorMsg=false;
                },1500)
                return
            }else if(that.checkEndDay==''){
                that.showErrorMsg=true;
                that.errormsg='结束时间不能为空';
                setTimeout(function(){
                    that.showErrorMsg=false;
                },1500)
                return
            }


            'staffIds yes array 员工id ["1212313","11231234"]';
            let params={
                // "beginTime":that.addDay+' '+that.workStartTime_2+':00',
                // "endTime":that.addDay+' '+that.workEndTime_2+':00',
                // "timeInterval":that.timevalue,
                // "streetOrgCode":that.triggerStreetId,
                // "sheetAreaOrgCode":that.triggerAreaId,
                // "socialAreaOrgCode":that.triggerCommunityId,
                // "communityOrgCode":that.triggerVillageId,
                //"staffId":that.repairPeopleStaffId,

                "communityIds":communityIds,
                "repairType":that.selectTypeId,
                "workTime":that.addDay,
                "staffIds":[that.repairPeopleStaffId],
                "beginTime": that.workStartTime_2,
                "endTime": that.workEndTime_2,
                "paragraphTime":that.timevalue,
                "beginDate":this.changeDateType(that.checkStartDay,2),
                "endDate":this.changeDateType(that.checkEndDay,2),//2021/06/18
            }
            // var date1=day.day.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,''); // 2020/01/01
            //
            // var date1=day.day.toLocaleDateString().replace(/(年|月)/g, '/').replace('日', '').replace(/[^\d-/]/g,''); // 2020/01/01

            that.bstapBtn=false;
             console.log(params);
             alert('结束');return;
            $.ajax({
                url : url,
                type: 'POST',
                dataType:'json',
                contentType: 'text/plain',
                headers:that.requestHeaders,
                data: JSON.stringify(params),
                success : function (res){
                    console.log('排班提交接口',res);
                    that.bstapBtn=true;
                    if(res.code=='200'){
                        that.showErrorMsg=true;
                        that.errormsg='新增成功！';
                        // console.log(that.selectTypeId,that.selectTypeValue)
                        that.getPersonNum(that.addDay);
                        that.repairPeopleStaffValue='请选择值班维修人员';
                        that.repairPeopleStaffId='';
                        that.selectTypeValue='维修类型';
                        that.selectTypeId='';
                        // console.log(day)
                        setTimeout(function(){
                            that.showErrorMsg=false;
                        },1500)
                        that.showSchedul=false;
                        setTimeout(function(){
                            that.showSchedulAll=false;
                        },350)
                        return;
                    }else{
                        that.errorPopup=true;
                        that.msg=res.msg
                    }
                },
                error:function(res){
                    that.bstapBtn=true;
                    that.errorPopup=true;
                    that.msg=res.responseText?res.responseText:'请求超时'
                }
            })
        },
        changeDateType(day,type=1){
            let date1 = day.day.toLocaleDateString().replace(/(年|月)/g, '-').replace('日', '-').replace(/[^\d-/]/g,'-');
            if(type == 1){
                return date1.split('/')[0] + '/'+this.addZero(date1.split('/')[1]) + '/' + this.addZero(date1.split('/')[2]);
            }
            return   date1.split('/')[0] + '-'+this.addZero(date1.split('/')[1]) + '-' + this.addZero(date1.split('/')[2]);
        },
        changeDateValue(){
            console.log(this.searchDate)
            var d=new Date(this.searchDate);
            var year=d.getFullYear();
            var month=d.getMonth()+1;
            var days=d.getDate();
            var day = {
                day:  new Date(this.formatDate(year,month, days)),
                text:this.isText(d),
                isSign: this.isVerDate(d),
                isSigned: this.isSigned(d),
                isToday:this.isToday(d)
            };
            d.setDate(0);
            this.initData(this.formatDate(year, month, 1));
            this.dayCheck(day,'yes');
        },
        timeBlur(){
            var that=this;
            if(this.timevalue>0 && this.timevalue<1440){
                this.timevalue=this.getInteger(this.timevalue)
            }else{
                this.showErrorMsg=true;
                this.errormsg='时间间隔为整数且不可超过1440(分钟)';
                setTimeout(function(){
                    that.showErrorMsg=false;
                },1500)
                this.timevalue='';
                return;
            }

        },
        //获取小数点前面的数字
        getInteger(num){
            var val=num.toString();
            if(val.indexOf('.')==-1){
                return val;
            }else{
                return val.substring(0,val.indexOf('.'))
            }
        },
        //时分比较
        timeComparison(start,end){
            //分割开始时间的时
            let kaiShi = start.split(":")[0];
            //分割开始时间的分
            let kaiFen = start.split(":")[1];
            //分割结束时间的时
            let jieShi = end.split(":")[0];
            //分割结束时间的分
            let jieFen = end.split(":")[1];
            //判断两者的时
            if(kaiShi < jieShi){
                return false;
            }else if(kaiShi == jieShi){
                //如果等于的话就判断两者的分
                if(kaiFen < jieFen){
                    return false;
                }else{
                    return true;
                }
            }else{
                return true;
            }
        },
        uuid() {
            let s = [];
            let hexDigits = "0123456789abcdef";
            for (let i = 0; i < 36; i++) {
                s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
            }
            s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
            s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
            s[8] = s[13] = s[18] = s[23] = "-";

            let uuid = s.join("");
            return uuid;
        },
        getDateYYYYMMDDHHMISS(){
            let date = new Date();
            let year = date.getFullYear();
            let month = date.getMonth() + 1;
            let day = date.getDate();
            let hour = date.getHours();
            let minute = date.getMinutes();
            let second = date.getSeconds();

            if (month < 10) {
                month = '0' + month;
            }

            if (day < 10) {
                day = '0' + day;
            }

            if (hour < 10) {
                hour = '0' + hour;
            }

            if (minute < 10) {
                minute = '0' + minute;
            }

            if (second < 10) {
                second = '0' + second;
            }

            return year + "" + month + "" + day + "" + hour + "" + minute + "" + second;
        },
        getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg); //匹配目标参数
            if (r != null) return unescape(r[2]);
            return null; //返回参数值

        },

        //添加值班人员先判断维修类型是否已选
        addPeople(){
            var that=this;
            this.showErrorMsg=true;
            this.errormsg='请先选择维修类型';
            setTimeout(function(){
                that.showErrorMsg=false;
            },1500)
            return;
        },

        //显示选择小区
        clickShow(index){
            this.showVillage=true;
            this.clickIndex=index; //点击添加后的第几个
        },
        //新增小区
        addCommunity(){
            this.addIndexId++
            this.multiColumnList.push({
                id:this.addIndexId,
                triggerVillageValue:'',
                triggerVillageId:'',
                showRemoveIcon:true
            })
            console.log(this.multiColumnList)
        },
        //删除小区
        removeCommunity(item){
            var listLength=this.multiColumnList.length;
            var that=this;
            for(let i=0;i<listLength;i++){
                if(that.multiColumnList[i]==item){
                    that.multiColumnList.splice(i,1)
                }
            }
        },
        // 显示小区
        clickVillageShow(){
            this.showVillage=true;

        },
        //小区确定按钮
        onConfirm(value, index) {
            console.log()
            console.log(value,this.multiColumnList)
            this.multiColumnList[this.clickIndex].triggerVillageValue=value.text;
            this.multiColumnList[this.clickIndex].triggerVillageId=value.value;
            // this.triggerVillageId=value.value;//小区Id
            // this.triggerVillageValue=value.text;
            this.showVillage=false;
        },
    }
});